﻿namespace Guia.Elements.PatternServants
{
    using System.Windows.Automation;

    /// <summary>
    /// Represents the implementation of the GridItem-Pattern.
    /// </summary>
    public class GridItemImpl : AbstractPatternServant, IGridItem
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GridItemImpl"/> class. 
        /// </summary>
        /// <param name="uiElement">
        /// The UiElement for which the servant provides functionality.
        /// </param>
        public GridItemImpl(UiElement uiElement)
            : base(uiElement)
        {
        }

        #region IGridItem Members

        /// <summary>
        /// Gets the number of the grid-item's row.
        /// </summary>
        public int Row
        {
            get
            {
                return this.UiElement.GetPattern<GridItemPattern>().Current.Row;
            }
        }

        /// <summary>
        /// Gets the number of the grid-item's column.
        /// </summary>
        public int Column
        {
            get
            {
                return this.UiElement.GetPattern<GridItemPattern>().Current.Column;
            }
        }

        /// <summary>
        /// Gets the grid-item's row-span.
        /// </summary>
        public int RowSpan
        {
            get
            {
                return this.UiElement.GetPattern<GridItemPattern>().Current.RowSpan;
            }   
        }

        /// <summary>
        /// Gets the grid-item's column-span.
        /// </summary>
        public int ColumnSpan 
        {
            get
            {
                return this.UiElement.GetPattern<GridItemPattern>().Current.ColumnSpan;
            }            
        }

        #endregion
    }
}
